<!-- 交补天数 -->
<template>
    <div class="div-box">
        <div class="acea-row row-right mb15 ">
            <!-- <a-input-search placeholder="工号/姓名" enter-button @search="onSearch" style="width: 200px;margin-right: 15px;" v-model="key"/>
            <a-month-picker  v-model="day" :disabled-date="disabledDate" placeholder="选择日期" @change="dateChange"  :defaultValue="day"
  valueFormat="YYYY-MM"/> -->
            <a-button type="primary" class="ml15" @click="exports">导出</a-button>
        </div>

        <a-table :columns="columns" :data-source="tableData" bordered size="middle" :rowKey="record => record.wokecode"
            :loading="loading" :pagination="false">
        </a-table>


    </div>
</template>
<script>
import { defineComponent } from 'vue';
import moment from "moment";
import { request } from "../../utils/request";
const columns = [
    {
        width: 50,
        align: 'center',
        title: '姓名',
        dataIndex: 'userName',
        key: 'userName',
    },
    {
        width: 50,
        align: 'center',
        title: '部门',
        dataIndex: 'departmentName',
        key: 'departmentName',
    },
    {
        width: 50,
        align: 'center',
        title: '日期',
        dataIndex: 'rq',
        key: 'rq',
    },
    {
        width: 100,
        title: '位置',
        dataIndex: 'wz',
        key: 'wz',
    },
    {
        width: 300,
        title: '昨日',
        dataIndex: 'zr',
        key: 'zr',
        customRender: (val, row) => {
            return <span v-html={val.text}></span>
        }
    },
    {
        width: 300,
        title: '今日',
        dataIndex: 'jr',
        key: 'jr',
        customRender: (val, row) => {
            return <span v-html={val.text}></span>
        }
    },
];
const tableData = [];
export default defineComponent({
    data() {
        return {
            tableData,
            columns,
            key: '',
            day: moment().subtract(1, 'month').startOf('month').format('YYYY-MM'),
            loading: false
        };
    },
    methods: {
        init() {
            this.list();
        },
        list() {
            this.loading = true
            request({
                url: "/api/OAXsrb/xsrb",
                method: "get",
            }).then((res) => {
                this.tableData = res;
                this.loading = false
            });
            // end
        },
        exports() {
            // let params = {
            //     day: this.day,
            //     key: this.key
            // }
            request({
                url: "/api/OAXsrb/xsrb/export",
                method: "get",
                // params
            }).then((res) => {
                window.location.href = `api` + res;
            });
        },
        onSearch(value) {
            this.key = value
            this.list()
        },
        dateChange(e) {
            this.day = e;
            this.list()
        }
    },
    created() {
        this.init();
    },
});
</script>
<style scoped>
.div-box {
    padding: 20px;
    font-size: 12px;
}
</style>